package cn.xz.mxxz.adapter


import android.graphics.Color
import android.graphics.drawable.Drawable
import android.view.ViewGroup
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import cn.xz.mxxz.R
import cn.xz.mxxz.bean.NetListBean
import cn.xz.mxxz.util.AppHelper
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class NetListAdapter :BaseQuickAdapter<NetListBean, BaseViewHolder>(R.layout.item_net_list) {

    override fun convert(helper: BaseViewHolder, item: NetListBean) {
        //总布局
        val clGetList = helper.getView<ConstraintLayout>(R.id.cl_get_list)
        //第一条不显示分割线
        if (helper.adapterPosition == 0){
            helper.setGone(R.id.view_line,true)
        }

        val tvGetTxt = helper.getView<TextView>(R.id.tv_get_txt)
        tvGetTxt.text = item.Name

        //选中资源
        val selectRes: Drawable? = AppHelper.getDrawable(R.mipmap.icon_zt_yes)
        var mDrawable: Drawable? = null
        if (item.select) {
            tvGetTxt.setTextColor(Color.parseColor("#FFFFFF"))
            mDrawable = selectRes
        } else {
            tvGetTxt.setTextColor(Color.parseColor("#00E7F7"))
        }
        clGetList.background = mDrawable
    }
}